//
//  LzwBangumiDetailHeaderView.m
//  CoJellyCartoon
//
//  Created by 刘志武 on 16/4/5.
//  Copyright © 2016年 CJG. All rights reserved.
//

#import "LzwBangumiDetailHeaderView.h"
#import "UIImage+Blur.h"

@interface LzwBangumiDetailHeaderView ()

@property (nonatomic, strong) UIImageView *imageBack;
@property (nonatomic, strong) UIImageView *imageTitle;

@property (nonatomic, strong) UILabel *lableTitle;
@property (nonatomic, strong) UILabel *lableContent;
@property (nonatomic, strong) UILabel *lablePlay;


@end

@implementation LzwBangumiDetailHeaderView

-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        [self creatdetailSubviews];
        self.backgroundColor = [UIColor whiteColor];
    }
    
    return self;
}

- (void)creatdetailSubviews{
    
    self.imageBack = [[UIImageView alloc]init];
    [self addSubview:self.imageBack];
    
    self.imageTitle = [[UIImageView alloc]init];
    [self addSubview:self.imageTitle];
    
    self.lableTitle = [[UILabel alloc]init];
    self.lableTitle.text = @"标题";
    self.lableTitle.textColor = [UIColor whiteColor];
    [self addSubview:self.lableTitle];
    
    self.lableContent = [[UILabel alloc]init];
    self.lableContent.font = [UIFont systemFontOfSize:15];
    self.lableContent.textColor = [UIColor whiteColor];

    self.lableContent.text = @"已完结";
    [self addSubview:self.lableContent];
    
    self.lablePlay = [[UILabel alloc]init];
    self.lablePlay.font = [UIFont systemFontOfSize:15];
    self.lablePlay.textColor = [UIColor whiteColor];

    self.lablePlay.text = @"播放次数";
    [self addSubview:self.lablePlay];
    
    
    [self.imageBack mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.left.equalTo(self);
        make.width.equalTo(self);
        make.height.mas_equalTo(250);
        
    }];
    
    [self.imageTitle mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self).offset(50);
        make.left.equalTo(self).offset(15);
        make.width.mas_equalTo(120);
        make.height.mas_equalTo(180);
        
    }];
    
    
    [self.lableTitle mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self).offset(60);
        make.left.equalTo(self.imageTitle.mas_right).offset(10);
        make.width.mas_equalTo(200);
        make.height.mas_equalTo(20);
        
    }];
    
    [self.lableContent mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.lableTitle.mas_bottom).offset(20);
        make.left.equalTo(self.imageTitle.mas_right).offset(10);
        make.width.height.equalTo(self.lableTitle);
        
    }];
    
    [self.lablePlay mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.lableContent.mas_bottom).offset(20);
        make.left.equalTo(self.imageTitle.mas_right).offset(10);
        make.width.height.equalTo(self.lableContent);
        
    }];
    
    
    
}


-(void)setModelDetail:(LzwBangumiDetailModle *)modelDetail{
    
    _modelDetail = modelDetail;
    
    NSURL *url = [NSURL URLWithString:_modelDetail.cover];
    
//    NSData *data = [NSData dataWithContentsOfURL:url];
    
//   UIImage *image = [[UIImage imageWithData:data] boxblurImageWithBlur:0.9];
    
//    self.imageBack.image = image;
    
    [self.imageBack sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"zhanweiye"]];
    
    
    [self.imageTitle sd_setImageWithURL:url placeholderImage:nil];
    
    self.lableTitle.text = _modelDetail.title;
    
    NSString *str = @"话全";
    
    NSString *str1 = [NSString stringWithFormat:@"%ld", _modelDetail.total_count];
    
    self.lableContent.text = [str1 stringByAppendingString:str];
    
    NSString *string1 = @"播放次数:";
    NSString *string = _modelDetail.play_count;
    
    self.lablePlay.text = [string1 stringByAppendingString:string];
    
    
}


@end
